import React, { Component } from 'react'
import Quill from 'quill'
import 'quill/dist/quill.snow.css'
export default class QuillEditor extends Component {
  componentDidMount(){
    //建立富文本编辑器
    var quill = new Quill('#editor', {
      modules: {
        toolbar: [
          [{ header: [1, 2, false] }],
          ['bold', 'italic', 'underline'],
          ['image', 'code-block']
        ]
      },
      placeholder: '请输入商品描述',
      theme: 'snow'  // or 'bubble'
    })
    quill.on('text-change', (delta, oldDelta, source) => {
      //console.log(oldDelta.ops[0].insert)
      this.props.getContent(oldDelta.ops[0].insert)
    });
  }
  render() {
    return (
      <div id="editor">
      </div>
    )
  }
}
